import java.util.*;

public class BucketSort {
    /**
     *
     * @param array
     */
    public static void sort(int[]array){
        int length=array.length;
        int min=0;
        int max=0;
        for (int i=0;i<length;i++){
            if(min>=array[i]){
                min=array[i];
            }
            if (max<=array[i]){
                max=array[i];
            }
        }
        List<LinkedList<Integer>> bucketList = new ArrayList<>(length);
        for (int i = 0;i<length;i++){
            bucketList.add(new LinkedList<>());
        }
        for (int i=0;i<length;i++){
            int num =(array[i]-min)/((max-min)/(length-1));
            bucketList.get(num).add(array[i]);
        }
        for (int i =0;i<length;i++){
            Collections.sort(bucketList.get(i));
        }

        int k =0;
        for (LinkedList<Integer> bucket:bucketList) {
            for (int bucketIndex:bucket) {
                array[k++]=bucketIndex;
            }
        }

        for (int i=0;i<length;i++){
            System.out.print(array[i]);
        }
    }

    public static void main(String[] args) {
        int[] array={3,8,9,1,2,4,5,7,0,6};
        sort(array);
    }
}
